<%@ page language="java" pageEncoding="utf-8"%>
<%@page import="java.util.List,com.witframework.components.CustomSelectEcProperty"%>
<%@page import="com.witframework.util.BeanUtils"%>
<%@page import="com.witframework.web.mvc.WebContext"%>
<%@page import="java.util.Map"%>
<%@ include file="/WEB-INF/classes/com/witframework/webroot/framework/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<%@ include	file="/WEB-INF/classes/com/witframework/webroot/framework/common/meta.jsp"%>
<script>
function setSelected(checked,value){
	var selectedItemsObject= document.getElementById("selectedItems");
	var selectedObject=document.getElementById("selected");
	id=value;
	if(value.indexOf("|")>0) id=value.substring(0,value.indexOf("|"));
	if(checked){		
		if(selectedItemsObject.value.length>0){
			if(selectedItemsObject.value.indexOf(value)==-1)
				selectedItemsObject.value=selectedItemsObject.value+";"+value;
		}
		else
			selectedItemsObject.value=value;
				
		if(selectedObject.value.length>0){
			if(selectedObject.value.indexOf("{"+id+"}")==-1)
				selectedObject.value=selectedObject.value+"{"+id+"}";
		}
		else
			selectedObject.value="{"+id+"}";		
	}else{
		selectedItemsObject.value=selectedItemsObject.value.replace(";"+value,"");
		selectedItemsObject.value=selectedItemsObject.value.replace(value,"");		
		selectedObject.value=selectedObject.value.replace("{"+id+"}","");
		selectedObject.value=selectedObject.value.replace("{"+id+"}","");		
	}
	getObject(parent.document,"selectedItems").value=selectedItemsObject.value;
	getObject(parent.document,"selected").value=selectedObject.value;
	document.getElementById('ok').focus();
}
function getEventType(e){ 
    var keynuml;
  	if(window.event){ // IE  
 		keynum = e.keyCode;
  	}
	else if(e.which){//Netscape/Firefox/Opera  	
  		keynum = e.which;
  	}
  	
}
</script
</head>
<%
String selected=(String)request.getAttribute("selected");
String filterOptions=(String)request.getAttribute("filterOptions");
%>
<body>	
	<form name="form1" action="dataSetAuthSelectController" method="post">
		<%if(filterOptions!=null){%>
		<table width="99%">			
			<tr>
				<td align="left" class="operation">
					<table><tr>
					<%						
						if(filterOptions!=null){
							int fc=0;int cols=6;
							for(String opt:filterOptions.split(",")){
								String[] oAndp=opt.split(":");													
								%>
								<td><%=oAndp[1]%>:</td>
								<%fc++;if(fc>1&&fc%cols==0) out.print("</tr><tr>");%>
								<td class="filter">
									<input name="__<%=oAndp[1]%>" type="type" size="10" value="<%=new WebContext(request,response).getParameterOrEmpty("__"+oAndp[1])%>">
									<%	
										if(oAndp[0].equalsIgnoreCase("between")){											 
									%>
									</td><td>到</td><td class="filter">
									<input name="__<%=oAndp[1]%>2" type="type" size="10" value="<%=new WebContext(request,response).getParameterOrEmpty("__"+oAndp[1]+"2")%>">
									<%fc++;if(fc>1&&fc%cols==0) out.print("</tr><tr>");}%>
									<input name="_s_expression_<%=oAndp[1]%>" type="hidden" 
										value="<%=oAndp[0]%>(<%=oAndp[1]%>,__<%=oAndp[1]%><%=oAndp[0].equalsIgnoreCase("like")?(","+oAndp[2]):""%><%=oAndp[0].equalsIgnoreCase("between")?(",__"+oAndp[1]+"2"):""%>)">
								</td>
								<%fc++;if(fc>1&&fc%cols==0) out.print("</tr><tr>");
							}
						}
					%>
							
						</tr>
					</table>
				</td>		
				<td align=right class="operation">
					<%if(filterOptions!=null){ %>
					<a href="#" onclick="query(document.form1,'dataSetAuthSelectController.wit');" accesskey="c">
						<img src="${contextPath}/webresource/images/ico_btn_search.gif">
						查询(F)
					</a>
					<%} %>									
				</td>		
			</tr>			
		</table>
		<%} %>
		<div id="customSelectDialogDiv">
					<ec:table items="dataList" var="item"
						tableId="${dialogid}"
						action="dataSetAuthSelectController.wit"
						state="persist"
						ajax="true"  width="98%"
						form="form1"
						filterRowsCallback="org.extremecomponents.table.callback.ProcessRowsCallback"
						sortRowsCallback="org.extremecomponents.table.callback.ProcessRowsCallback"
						retrieveRowsCallback="org.extremecomponents.table.callback.ProcessRowsCallback"
						rowsDisplayed="12"						
						>
						<ec:row>					
							<ec:column property="checkbox2" title=" " sortable="false" width="1%" viewsAllowed="html">
								<input type="checkbox" name="itemlist" style="border: 0px"
									value="<%="${item."+request.getAttribute("property1")+"}"%><%=request.getAttribute("property2")!=null?("|${item."+request.getAttribute("property2")+"}"):""%><%=request.getAttribute("property3")!=null?("|${item."+request.getAttribute("property3")+"}"):""%>" 
									
									onMouseOut="setSelected(this.checked,this.value);" 
									<%
									Object o=pageContext.getAttribute("item");
									StringBuffer v=new StringBuffer("{}");
									if(o instanceof Map){
										v.insert(1,(String)((Map)o).get(request.getAttribute("property1")));
									}									
									%>
									<%=(selected!=null&& selected.contains(v.toString()))?"checked":""%>
									 />
							</ec:column>	
								<%
						            List<CustomSelectEcProperty> viewPropertyList=(List<CustomSelectEcProperty>)request.getAttribute("viewPropertyList");
						            for(CustomSelectEcProperty cp:viewPropertyList){
					            %>            	
					            	<ec:column property="<%=cp.getName()%>" alias="<%=cp.getName()%>" title="<%=cp.getTitle()%>"/>			
					            <%
					            	}
					            %>
						</ec:row>
					</ec:table>	
					<br>
		</div>
			<input type="hidden" name="data" value="${data}"/>
			<input type="hidden" name="properties" value="${properties}"/>
			<input type="hidden" name="category" value="${category}"/>
			<input type="hidden" name="entryid" value="${entryid}"/>
			<input type="hidden" name="entryname" value="${entryname}"/>
			<input type="hidden" name="datatype" value="${datatype}"/>
			<input type="hidden" name="datastyle" value="${datastyle}"/>	
			<input type="hidden" name="titles" value="${titles}"/>	
			<input type="hidden" name="multiple" value="${multiple}"/>	
			
			<input type="hidden" name="data2" value="${data2}"/>
			<input type="hidden" name="root" value="${root}"/>
			<input type="hidden" name="parentid" value="${parentid}"/>
			<input type="hidden" name="nodeid" value="${nodeid}"/>
			<input type="hidden" name="nodeid2" value="${nodeid2}"/>
			<input type="hidden" name="nodelabel" value="${nodelabel}"/>
			<input type="hidden" name="nodelabel2" value="${nodelabel2}"/>
			<input type="hidden" name="onlyLeaf" value="${onlyLeaf}"/>
			<input type="hidden" name="height" value="${height}"/>
			<input type="hidden" name="width" value="${width}"/>
						
			<input type="hidden" name="dialogid" value="${dialogid}"/>	
			<input type="hidden" name="property1" value="${property1}"/>
			<input type="hidden" name="property2" value="${property2}"/>
			<input type="hidden" name="property3" value="${property3}"/>
			<input type="hidden" id="selected" name="selected" value="${selected}" size="128"/>
			<input type="hidden" id="selectedItems" name="selectedItems" value="${selectedItems}" size="128"/>
			<input type="hidden" name="filterOptions" value="${filterOptions}" />
			<input type="hidden" name="filters" value="${filters}" />		
	</form>
</body>
</html>